package com.qpx.jxcupms.web;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.qpx.jxc.common.vo.ResultEntity;
import com.qpx.jxcupms.entity.TMenu;
import com.qpx.jxcupms.service.ITMenuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;
import java.util.List;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Mht
 * @since 2020-05-26
 */
@RestController
@RequestMapping("/tMenu")
@Slf4j
public class TMenuController {

    @Autowired
    ITMenuService itMenuService;
    @RequestMapping("/test")
    public ResultEntity test(){
        Wrapper wrapper = new EntityWrapper<TMenu>();
        return ResultEntity.ok(itMenuService.selectList(wrapper));
    }

    @RequestMapping("/getMenuByUserName")
    public ResultEntity getMenuByUserName(Principal member){

        log.info("登录成功后的用户名是:{}",member.getName());
        List<TMenu> menuByUserName = itMenuService.getMenuByUserName(member.getName());

        return ResultEntity.ok(menuByUserName);
    }


}
